home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr46 / vfwdk.zip / VFWSDK.ZIP / SAMPLES / WRITEAVI / MULDIV32.ASM < prev    next >
Assembly Source File  |  1993-01-31  |  2KB  |  72 lines

  1.         page    ,132
  2. ;---------------------------Module-Header-------------------------------;
  3. ; Module Name: MULDIV32
  4. ;
  5. ; Copyright (c) 1987-1993  Microsoft Corporation
  6. ;-----------------------------------------------------------------------;
  7.  
  8. ?WIN    = 0
  9. ?PLM    = 1
  10. ?NODATA = 0
  11.  
  12.         .xlist
  13.         include cmacros.inc
  14.         include windows.inc
  15.         .list
  16.  
  17. ifndef SEGNAME
  18.     SEGNAME equ <_TEXT>
  19. endif
  20.  
  21. createSeg %SEGNAME, CodeSeg, word, public, CODE
  22.  
  23. sBegin  CodeSeg
  24.         .386
  25.         assumes cs,CodeSeg
  26.     assumes ds,nothing
  27.         assumes es,nothing
  28.  
  29. ;---------------------------Public-Routine------------------------------;
  30. ; muldiv32
  31. ;
  32. ; multiples two 32 bit values and then divides the result by a third
  33. ; 32 bit value with full 64 bit presision
  34. ;
  35. ; lResult = (lNumber * lNumerator) / lDenominator
  36. ;
  37. ; Entry:
  38. ;       lNumber = number to multiply by nNumerator
  39. ;       lNumerator = number to multiply by nNumber
  40. ;       lDenominator = number to divide the multiplication result by.
  41. ;   
  42. ; Returns:
  43. ;       DX:AX = result of multiplication and division.
  44. ; Error Returns:
  45. ;       none
  46. ; Registers Preserved:
  47. ;       DS,ES,ESI,EDI
  48. ;-----------------------------------------------------------------------;
  49.         assumes ds,nothing
  50.         assumes es,nothing
  51.  
  52. cProc   muldiv32,<PUBLIC,FAR,PASCAL>,<>
  53. ;       ParmD  ulNumber
  54. ;       ParmD  ulNumerator
  55. ;       ParmD  ulDenominator
  56. cBegin
  57.         pop     edx     ; return addr
  58.         pop     ebx     ; ulDenominator
  59.         pop     ecx     ; ulNumerator
  60.         pop     eax     ; ulNumber
  61.         push    edx     ; put back return addr
  62.  
  63.         imul    ecx     ; edx:eax = (lNumber * lNumerator)
  64.         idiv    ebx     ; eax     = (lNumber * lNumerator) / lDenominator
  65.  
  66.         shld    edx,eax,16      ; move HIWORD(eax) to dx
  67. cEnd
  68.  
  69. sEnd   CodeSeg
  70.  
  71.        end
  72.